package com.itheima;

import java.util.Scanner;

public class Test08 {

    //编写程序可以从控制台接收6名评委的打分,然后要去掉最高分,去掉最低分，
    //剩下的分数除以4,就是选手最后得分,打印这名选手的最后得分。

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("请输入评委的个数");

        int num = sc.nextInt();

        int[] arr = new int[num];

        System.out.println("请输入" + num + "名评委对你的成绩：");

        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }

        int max = getMax(arr);

        int min = getMin(arr);

        int sum = getSum(arr);

        double score = (sum - max - min) / (arr.length - 2);

        System.out.println("你的最终得分是" + score + "分");
    }

    public static int getMax(int[] arr) {
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }
        }
        return max;
    }

    public static int getMin(int[] arr) {
        int min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] < min) {
                min = arr[i];
            }
        }
        return min;
    }

    public static int getSum(int[] arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        return sum;
    }

}
